package cn.shrek.controller;

import cn.shrek.bean.Student;
import cn.shrek.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *
 */
@RestController
public class ProviderController {
    @Autowired
    private StudentService service;

    /*通过id查找所有*/
    @PostMapping("/findById")
    public List<Student> findById(@RequestParam("s_id") Integer s_id){
        List<Student> list = service.findById(s_id);
        return list;
    }
    /*查找所有*/
    @GetMapping("/findAll")
    public List<Student> index(){
        List<Student> list = service.findAll();
        return list;
    }

    @PostMapping("/add")
    public void add(@RequestBody Student Student){
        service.add(Student);
    }

    @PostMapping("/update")
    public void update(@RequestBody Student Student){
      service.update(Student);
    }

    @PostMapping("/delete")
    public int delete(@RequestParam("s_id") int s_id){
        int delete = service.delete(s_id);
        return delete;
    }






}
